﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FFS.Model;
using FFS.BLL;

namespace FFS
{
    public partial class frmChangeLoginUser : Form
    {
        public frmChangeLoginUser()
        {
            InitializeComponent();
        }

        LoginUserInfo user = new LoginUserInfo();
        List<LoginUserInfo> userList = new List<LoginUserInfo>();
        LoginUserService userService = new LoginUserService();

        private void frmChangeLoginUser_Load(object sender, EventArgs e)
        {
            this.cmb_LoginUserName.Text = Context._Login_UserName;
            this.AcceptButton = this.btn_Login;
        }

        private void btn_Login_Click(object sender, EventArgs e)
        {
            if (userService.ManageLoginUser().VerifyLogin(this.cmb_LoginUserName.Text.ToString().Trim(), this.txt_LoginPassword.Text))
            {
                Context._Login_UserName = this.cmb_LoginUserName.Text.ToString().Trim();
                if (this.cmb_LoginUserName.AutoCompleteCustomSource.Contains(Context._Login_UserName))
                {
                    this.cmb_LoginUserName.AutoCompleteCustomSource.Add(Context._Login_UserName);
                    this.cmb_LoginUserName.Items.Add(Context._Login_UserName);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或者密码错误，请重新输入！","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                this.txt_LoginPassword.SelectAll();
            }
            
        }
    }
}
